home *** CD-ROM | disk | FTP | other *** search
- The Delphi Cheat Sheet
-
- <IMG "DELLOGO.BMP">
-
- A compilation of online tips, tricks, techniques, workarounds,
- and hacks for Delphi 1.0 and Delphi 2.0.
-
- Click on a letter below to move to that section of the index.
- Then click on the title of the tip you wish to examine.
-
- To bring up the floating toolbar, right click anywhere not
- show the hand cursor.
-
- This file is an example taken from the larger and continually updated files at
- www.tde.com/ciupkc/cheatsht.html. Please feel free to drop by for a look!
-
- Enjoy!
-
- <A NAME="TheTop">Alphabetical Topic List</A>
-
- <A HREF="#IndexA">A </A> <A HREF="#IndexB">B </A> <A HREF="#IndexC">C </A><A HREF="#IndexD">D </A> <A HREF="#IndexE">E </A>
- <A HREF="#IndexF">F </A><A HREF="#IndexG">G </A> <A HREF="#IndexH">H </A> <A HREF="#IndexI">I </A> <A HREF="#IndexJ">J </A>
- <A HREF="#IndexK">K </A> <A HREF="#IndexL">L </A><A HREF="#IndexM">M </A> <A HREF="#IndexN">N </A> <A HREF="#IndexO">O </A>
- <A HREF="#IndexP">P </A> <A HREF="#IndexQ">Q </A> <A HREF="#IndexR">R </A><A HREF="#IndexS">S </A> <A HREF="#IndexT">T </A>
- <A HREF="#IndexU">U </A><A HREF="#IndexV">V </A> <A HREF="#IndexW">W </A> <A HREF="#IndexX">X </A> <A HREF="#IndexY">Y </A>
- <A HREF="#IndexZ">Z </A>
-
- <A NAME="IndexA">Section A</A>
-
- <A HREF="#Ampersand">Ampersand Enabling In TLabel</A>
-
- <A NAME="IndexB">Section B</A>
-
- <A HREF="#Blocks">Persistent Block Marking</A>
-
- <A NAME="IndexC">Section C</A>
-
- <A HREF="#Colors">Using RGB Colors With TColor</A>
-
- <A NAME="IndexD">Section D</A>
-
- <A HREF="#DCRBug">DCR Uppercase Name Bug</A>
-
- <A NAME="IndexE">Section E</A>
-
- <A HREF="#Errors">Turning Off Exception Handling in the IDE</A>
-
- <A NAME="IndexF">Section F</A>
-
- <A HREF="#FMXUCopyBug">FileCopy Bug</A>
-
- <A NAME="IndexG">Section G</A>
-
- <A HREF="#GraphicsDrawBug">Position Bug in TCanvas.Draw</A>
-
- <A NAME="IndexH">Section H</A>
-
- <A HREF="#HWLIB">Hardwired \LIB in VCL Path</A>
-
- <A NAME="IndexI">Section I</A>
-
- <A HREF="#BigImage">Image Loading Failures</A>
-
- <A NAME="IndexJ">Section J</A>
-
- <A HREF="#Justification">Vertical Label Text Justification</A>
-
- <A NAME="IndexK">Section K</A>
-
- <A HREF="#Keypress">Trapping Keypresses</A>
-
- <A NAME="IndexL">Section L</A>
-
- <A HREF="#FListboxBug">FileListbox Count Bug</A>
-
- <A NAME="IndexM">Section M</A>
-
- <A HREF="#MultiImage">Displaying same bitmap in multiple images</A>
-
- <A NAME="IndexN">Section N</A>
-
- <A HREF="#NewError">Common Error Creating New Components</A>
-
- <A NAME="IndexO">Section O</A>
-
- <A HREF="#OrderShow">Controlling Order of display of Images</A>
-
- <A NAME="IndexP">Section P</A>
-
- <A HREF="#PaletteBug">Bug in TImage with 256 color palettes</A>
-
- <A NAME="IndexQ">Section Q</A>
-
- <A HREF="#QuickFlip">Quickly changing listbox contents</A>
-
- <A NAME="IndexR">Section R</A>
-
- <A HREF="#ResizeBug">Resize Bug in TCombobox</A>
-
- <A NAME="IndexS">Section S</A>
-
- <A HREF="#SymbolError">Avoiding "Error Loading Symbol File" message</A>
-
- <A NAME="IndexT">Section T</A>
-
- <A HREF="#Terminate">Resource-safe instant program termination</A>
-
- <A NAME="IndexU">Section U</A>
-
- <A HREF="#UnlimitedBMP">Loading Unlimited Size TBitmaps</A>
-
- <A NAME="IndexV">Section V</A>
-
- <A HREF="#VerSBRange">Controlling Vertical Scrollbox size at runtime</A>
-
- <A NAME="IndexW">Section W</A>
-
- <A HREF="#WorkPict">Using TPictureEditor to Work with TPictures in the IDE</A>
-
- <A NAME="IndexX">Section X</A>
-
- <A HREF="#XCopy">XCopy command</A>
-
- <A NAME="IndexY">Section Y</A>
-
- <A HREF="#YXOrder">X and Y coordinates common mistake</A>
-
- <A NAME="IndexZ">Section Z</A>
-
- <A HREF="#ZOrder">Controlling Z Order of Controls</A>
-
- ===============================================================
-
- <A NAME="Ampersand">Ampersand Enabling in TLabel</A>
-
- To enable or disable the & character to become an underline,
- use the ShowAccelChar property. If true, the & becomes an
- underline. If false, it become the & character
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="Blocks">Persistent Block Marking</A>
-
- Use the OPTIONS|EDITOR "Persistent Blocks" checkbox for this one.
- (another annoying "feature"...)
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="Colors">Using RGB Colors With TColor</A>
-
- The TColor property will accept RGB colors output from Windows
- API calls.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="DCRBug">DCR Uppercase Name Bug</A>
-
- You MUST put the name of your component in UPPERCASE in the DCR
- file or the IDE won't find it, regardless of capitalization in
- the PAS file.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="Errors">Turning Off Exception Handling in the IDE</A>
-
- Use the OPTIONS|ENVIRONMENT "break on Exception" checkbox. (dratted
- nuisance if you don't happen to notice that sucker...)
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="FMXUCopyBug">FileCopy Bug</A>
-
- FMXU has a problem differentiating between files and directories.
- The FMXU elsewhere on this site doesn't.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="GraphicsDrawBug">Position Bug in TCanvas.Draw</A>
-
- If you issue a Canvas.Draw( 0 , 0 , MyGraphic ) it will not always draw.
- Canvas.Draw( 1 , 1 , MyGraphic ) will always work.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="HWLIB">Hardwired \LIB in VCL Path</A>
-
- In older versions of Delphi, the VCL path has a hardwired \LIB in it,
- which makes using other directories for components impossible. The fix is
- to upgrade to a newer version of Delphi.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="BigImage">Image Loading Failures</A>
-
- The TImage component won't load images larger than 64K. Use the
- TUnlimitedImage component elsewhere on this site to overcome this.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="Justification">Vertical Label Text Justification</A>
-
- The following code controls vertical label text justification:
-
- Label1.Height := Label1.Canvas.TextHeight( Label1.Caption ) + 2;
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="Keypress">Trapping Keypresses</A>
-
- Use the FormKeyDown event of TForm to trap keypresses to a form,
- and ControlKeyDown to trap those to components.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="FListboxBug">FileListbox Count Bug</A>
-
- The Count property of the FileListBox doesn't respond correctly
- at runtime. If you copy the Items to a stringlist, though, they
- are correctly counted.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="MultiImage">Displaying same bitmap in multiple images</A>
-
- Use this code to switch TImage bitmaps instantly:
-
- MyImage.Picture.Assign( TheOtherImage.Picture );
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="NewError">Common Error Creating New Components</A>
-
- Don't forget this is wrong:
-
- MyNewComponent.Create( self );!!!
-
- The correct syntax is:
-
- MyNewComponent := TMyNewComponent.Create( Self );
-
- otherwise you get a GPF!
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="OrderShow">Controlling Order of display of Images</A>
-
- You can control the display order of images by setting their ZOrder
- value via SendToFront and BringToBack methods.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="PaletteBug">Bug in TImage with 256 color palettes</A>
-
- THIS IS A BIGGIE!!!!
-
- The TImage does not set the Palette correctly, due to a failure
- to handle RealizePalette correctly. Fixes worked until the latest
- release, now they don't! New fixes are being researched...
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="QuickFlip">Quickly changing listbox contents</A>
-
- You can switch the contents of a listbox with the following
- single line of code:
-
- TheListbox.items.Assign( MyItemsStringList );
-
- where MyItemsStringList is a stringlist. Note that the old contents
- are destroyed automatically and cannot be regained.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="ResizeBug">Resize Bug in TCombobox</A>
-
- The TCombobox component, if resized at runtime, doesn't resize
- the windows-drawn portion of the display (ie the drop down box.)
- There is not a fix known at this time to the author.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="SymbolError">Avoiding "Error Loading Symbol File" message</A>
-
- To avoid getting the ubiquitous "Error Loading Symbol File" message,
- simply don't copy the DSM, OPT, or DSK files with the code to a new
- directory.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="Terminate">Resource-safe instant program termination</A>
-
- Use Application.Terminate for a fast, resource-safe way to halt a
- delphi EXE.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="UnlimitedBMP">Loading Unlimited Size TBitmaps</A>
-
- A TBitmap won't accept a bitmap larger than 64K in Delphi 1.0. See
- How To Three of Chapter Six of Delphi Developers Solutions for a fix!
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="VerSBRange">Controlling Vertical Scrollbox size at runtime</A>
-
- By setting the Range property of a scrollbox, you automatically change the
- size and existence of the vertical scrollbar.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="WorkPict">Using TPictureEditor to Work with TPictures in the IDE</A>
-
- You can use the TPictureEditor class as a property editor for TPicture components
- you write yourself for the IDE. It works identically to the Picture property of
- TImage components.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="XCopy">XCopy command</A>
-
- This isn't Delphi, but it's really neat! it copies directories recursively,
- and even sets the READONLY flag as a default (perfect for copying the RFC
- files from the CD!)
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="YXOrder">X and Y coordinates common mistake</A>
-
- It is easy to confuse Height and Width, Top and Left. Always remember
- that Height and Top are Y coordinates and Left and Width are X coordinates.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-
- <A NAME="ZOrder">Controlling Z Order of Controls</A>
-
- You can use the "bringtofront" and "sendtoback" methods of all controls and TForms
- to move them into view when hidden by other controls. (Note that this method does
- not work between non windows and windows controls; ie, a non windowed control will
- always draw BEHIND a windowed one.
-
- <A HREF="#TheTop">Back To Top</A>
- ===============================================================
-